﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace IceDog.Lib.Common
{
    public class IntObjectHelper
    {
        public IntObjectHelper()
            : this(default(int))
        {

        }
        public IntObjectHelper(int val)
        {
            this.Val = val;
        }
        private int _val;
        public int Val
        {
            get
            {
                return _val;
            }
            set
            {
                _val = value;
            }
        }


        public static IntObjectHelper operator +(IntObjectHelper val1)
        {
            return new IntObjectHelper() { Val = +val1.Val };
        }
        public static IntObjectHelper operator -(IntObjectHelper val1)
        {
            return new IntObjectHelper() { Val = -val1.Val };
        }
        public static IntObjectHelper operator !(IntObjectHelper val1)
        {
            return new IntObjectHelper() { Val = val1.Val > 0 ? -val1.Val : val1.Val };
        }
        public static IntObjectHelper operator ~(IntObjectHelper val1)
        {
            return new IntObjectHelper() { Val = ~val1.Val };
        }
        public static IntObjectHelper operator ++(IntObjectHelper val1)
        {
            return new IntObjectHelper() { Val = val1.Val + 1 };
        }
        public static IntObjectHelper operator --(IntObjectHelper val1)
        {
            return new IntObjectHelper() { Val = val1.Val - 1 };
        }
        public static bool operator true(IntObjectHelper val)
        {
            return val != null;
        }
        public static bool operator false(IntObjectHelper val)
        {
            return val != null;
        }


        public static IntObjectHelper operator +(IntObjectHelper val1, IntObjectHelper val2)
        {
            return new IntObjectHelper() { Val = val1.Val + val2.Val };
        }
        public static IntObjectHelper operator -(IntObjectHelper val1, IntObjectHelper val2)
        {
            return new IntObjectHelper() { Val = val1.Val - val2.Val };
        }
        public static IntObjectHelper operator *(IntObjectHelper val1, IntObjectHelper val2)
        {
            return new IntObjectHelper() { Val = val1.Val * val2.Val };
        }
        public static IntObjectHelper operator /(IntObjectHelper val1, IntObjectHelper val2)
        {
            return new IntObjectHelper() { Val = val1.Val / val2.Val };
        }
        public static IntObjectHelper operator %(IntObjectHelper val1, IntObjectHelper val2)
        {
            return new IntObjectHelper() { Val = val1.Val % val2.Val };
        }
        public static IntObjectHelper operator &(IntObjectHelper val1, IntObjectHelper val2)
        {
            return new IntObjectHelper() { Val = val1.Val & val2.Val };
        }
        public static IntObjectHelper operator |(IntObjectHelper val1, IntObjectHelper val2)
        {
            return new IntObjectHelper() { Val = val1.Val | val2.Val };
        }
        public static IntObjectHelper operator ^(IntObjectHelper val1, IntObjectHelper val2)
        {
            return new IntObjectHelper() { Val = val1.Val ^ val2.Val };
        }
        public static IntObjectHelper operator <<(IntObjectHelper val1, int val2)
        {
            return new IntObjectHelper() { Val = val1.Val << val2 };
        }
        public static IntObjectHelper operator >>(IntObjectHelper val1, int val2)
        {
            return new IntObjectHelper() { Val = val1.Val >> val2 };
        }

        public static bool operator >(IntObjectHelper val1, IntObjectHelper val2)
        {
            return val1.Val > val2.Val;
        }
        public static bool operator <(IntObjectHelper val1, IntObjectHelper val2)
        {
            return val1.Val < val2.Val;
        }
        public static bool operator >=(IntObjectHelper val1, IntObjectHelper val2)
        {
            return val1.Val >= val2.Val;
        }
        public static bool operator <=(IntObjectHelper val1, IntObjectHelper val2)
        {
            return val1.Val <= val2.Val;
        }
        public static bool operator ==(IntObjectHelper val1, IntObjectHelper val2)
        {
            return val1.Val == val2.Val;
        }
        public static bool operator !=(IntObjectHelper val1, IntObjectHelper val2)
        {
            return !(val1.Val == val2.Val);
        }
        public override bool Equals(object obj)
        {
            if (obj is IntObjectHelper)
            {
                return this.Val == ((IntObjectHelper)obj).Val;
            }
            else
            {
                throw new ArgumentException("cannot compare IntWrapper objects with objects of type " + obj.GetType().ToString()
                    , nameof(obj));
            }
        }
        public override int GetHashCode()
        {
            return this.Val;
        }
        public override string ToString()
        {
            return this.Val.ToString();
        }
    }
}
